package com.example.friend.controller.user;

import com.example.api.domain.vo.UserQuestionResultVO;
import com.example.common.core.Controller.BaseController;
import com.example.common.core.domin.R;
import com.example.friend.aspect.CheckUserStatus;
import com.example.friend.domain.user.dto.UserSubmitDTO;

import com.example.friend.service.user.IUserQuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user/question")
public class UserQuestionController extends BaseController {

    @Autowired
    private IUserQuestionService userQuestionService;

    //用户代码提交 -- 处理判题参数
    @PostMapping("/submit")
    public R<UserQuestionResultVO> submit(@RequestBody UserSubmitDTO userSubmitDTO) {
        return userQuestionService.submit(userSubmitDTO);
    }


    //用户代码提交 -- 处理判题参数(RabbitMQ版本)
    @PostMapping("/rabbit/submit")
    public R<Void> rabbitSubmit(@RequestBody UserSubmitDTO userSubmitDTO) {
        return toR(userQuestionService.rabbitSubmit(userSubmitDTO));
    }


    //获取判题结果
    @GetMapping("/exe/result")
    public R<UserQuestionResultVO> exeResult(Long examId,Long questionId,String currentTime) {
        return R.ok(userQuestionService.exeResult(questionId,examId,currentTime));
    }
}
